package trefliq.persistence.entity;

import java.io.Serializable;
import javax.persistence.*;

/**
 *
 * @author Mike S. 
 */
@Entity
// These are only needed for testing; moved to dynamic queries in test file.
//@NamedQueries( {
//    @NamedQuery(name=Credential.selectAll, query="select c from Credential c"),
//    @NamedQuery(name=Credential.countAll, query="select count(c) from Credential c")
//} )
public class Credential implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Basic(optional = false)
    private String userName;
    
    @Basic(optional = false)
    private String password;
    
    public Credential() {
        this.id = null;
        this.userName = new String();
        this.password = new String();
    }
    
    public Credential(Long id, String userName, String password) {
        this.id = id;
        this.userName = userName;
        this.password = password;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object o) {
        Credential other = (Credential) o;
        boolean equal = false;
        if ( o == null || !(o instanceof Credential)) {
            equal = false;
        }
        else if ( (this.id==null && other.id==null || this.id != null && other.id != null && this.id.equals(other.id)) &&
             (this.userName==null && other.userName==null || this.userName != null && other.userName != null && this.userName.equals(other.userName)) &&
             (this.password==null && other.password==null || this.password != null && other.password != null && this.password.equals(other.password)) ) {
            equal = true;
        }
        return equal;
    }

    @Override
    public String toString() {
        return "edu.depaul.se.jpa.basic.Credential[ id=" + id + ", userName=[" + userName + "], password=[" + password + "] ]";
    }

    /**
     * @return the userName
     */
    public String getUserName() {
        return userName;
    }

    /**
     * @param userName the userName to set
     */
    public void setUserName(String userName) {
        this.userName = userName;
    }

    /**
     * @return the password
     */
    public String getPassword() {
        return password;
    }

    /**
     * @param password the password to set
     */
    public void setPassword(String password) {
        this.password = password;
    }
    
}
